import urlparse,urllib2,re,sys
help="Deadfly - deadfly [adf.ly link] - Gets the end result of an adf.ly link."
restrict="null"
hide="false"
aliases = "df, dead, dfly, deadf"

#Thanks to _303! 
def start(channel, sender, usename, extra):
	if usename:
		start = sender+": "
	else:
		start = ""
	nyud=".nyud.net"
	l=list(urlparse.urlsplit(extra[0]))
	l[1]+=nyud
	url=urlparse.urlunsplit(l)
	result=re.search(r'var url = \'([^\']+)\'', urllib2.urlopen(url).read()).group(1)
   
	irc.sendMessage("##crow", start+result)
 